﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DLMemberPointMS.Entity.POCOModel;
using DLMemberPointMS.Common;
using DLMemberPointMS.Business;
using DLMemberPointMS.Entity;
using DLMemberPointMS.Entity.ViewModel;

namespace DLMemberPointMS.Web.Controllers
{
    public class UserController : Controller
    {
        private UserService _userService = new UserService();
        // GET: User
        public ActionResult Index()
        {
           
            return View();
        }
        public ActionResult BindUser()
        {
            return View();
        }
        [HttpPost]
      
     
        public ActionResult BindUser(UserPageSelect view)
        {
            var res = _userService.GetUserPage(view);
            return Json(res, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <returns></returns>
        public ActionResult UserInsert()
        {
            var model = EnumHelper.EnumListDic<URoleInsert>(" ", "0");
            var list = new SelectList(model, "value", "key");
            ViewData["Companys"] = list;
            return View();
        }
        [HttpPost]
        public ActionResult UserInsert(UserInsertView view)
        {
            var res = _userService.InsertUser(view);
            return Json(res, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult UserUpda(int id)
        {
            var model = EnumHelper.EnumListDic<URoleInsert>(" ", "0");
            var list = new SelectList(model, "value", "key");
            ViewData["Companys"] = list;

            var res = _userService.UserUpdateSelect(id).data;
            return View(res);
        }
        [HttpPost]
        public ActionResult UserUpda(UserInsertView view)
        {
            var res = _userService.UserUpdate(view);
            return Json(res, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult UserDele(int U_ID)
        {
            var res = _userService.UserDelete(U_ID);
            return Json(res);
        }



    }
}